export default {
    namespaced: true,
    state: {
        isShowToast: false,
        toastMsg: "提示框",
        toastType: "warning"    //success danger warning
    },
    mutations: {
        // 修改是否显示提示框的数据
        changeIsShowToast(state, payload) {
            state.isShowToast = payload.isShowToast;
            if (payload.isShowToast) {
                state.toastMsg = payload.toastMsg;
                state.toastType = payload.toastType;
            }
        }
    },
    actions: {
        asyncIsShowToast({ commit }, payload) {
            // 为了便于后续书写，把 { commit }=context.commit 解构出来
            // console.log('asyncIsShowToast执行了');
            // 第一步，显示提示框
            commit("changeIsShowToast", payload)
            // 第二步，关闭提示框
            setTimeout(() => {
                commit("changeIsShowToast", {
                    isShowToast: false
                })
            }, 1500)
        }
    }
}